<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Home extends CI_Controller {

//Global variable  
    public $outputData;  //Holds the output data for each view

    public function __construct() {
        parent::__construct();
        $this->load->model('Item_model', 'itemEntry');
        $this->outputData['item_index'] =0;
        
    }

    public function index() {
        //echo "sdfsdf";



        $session_id = $this->session->userdata('session_id');
        $user_id = $this->session->userdata('user_id');
        
        if ($this->session->userdata('logged_in')) {
            //User is logged in
            $this->outputData['category_1'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(1,$user_id);
            $this->outputData['category_2'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(2,$user_id);
            $this->outputData['category_3'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(3,$user_id);
            $this->outputData['category_4'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(4,$user_id);
            $this->outputData['category_5'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(5,$user_id);
        } else {
            //User is not logged in
            $this->outputData['category_1'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(1,$session_id);
            $this->outputData['category_2'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(2,$session_id);
            $this->outputData['category_3'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(3,$session_id);
            $this->outputData['category_4'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(4,$session_id);
            $this->outputData['category_5'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(5,$session_id);
            $this->outputData['category_6'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(6,$session_id);
            $this->outputData['category_7'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(7,$session_id);
        }

        $this->load->view('home', $this->outputData);
    }

//	public function create()
//	{
    //$this->input
//		if($_POST){
//		echo 'create';
//		//$this->load->view('home');
//		}else{
//		$this->load->view('home_create', $this->outputData);
//		}
//	    
    //$this->outputData['home_items'] = $this->home_model->getHomeById($id);
    //print_r($this->outputData['homeRows']);
    //$this->load->view('home', $this->outputData);
//	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */